package com.wxxymakers.cklabrecruit.entity.enum_;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import io.github.biezhi.excel.plus.converter.Converter;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @AUTHOR soft
 * @DATE 2018/11/4 21:12
 * @DESCRIBE 性别枚举
 */
@AllArgsConstructor
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum Sex {
    MAN("男"), WOMAN("女"), NAN("未知");

    @Getter
    private String name;

    @JsonValue
    public String value() {
        return name;
    }

    public static class SexConverter implements Converter<Sex> {

        @Override
        public String write(Sex value) {
            return value.getName();
        }

        @Override
        public Sex read(String value) {
            for (Sex sex : Sex.values()) {
                if (sex.getName().equals(value)) return sex;
            }
            return Sex.NAN;
        }
    }
}
